/**
 * File: ImagePicker.js
 * Project: App
 * Created Date: Wednesday 2018/03/07 15:32:05
 * Author: zhengjiang
 * -----
 * Last Modified: Thursday 2018/03/08 15:14:48
 * Modified By: zhengjiang
 * -----
 * Description: 
 * 
 */


import React, { Component } from 'react';
import { Image, StatusBar, StyleSheet, TouchableOpacity, View, Text } from 'react-native';

import ImagePicker from 'react-native-image-crop-picker';

export default class ImagePickers extends Component {
	constructor(props) {
		super(props);
	}

	openPicker = () => {
		ImagePicker.openPicker({
			width: 300,
			height: 400,
			cropping: true
		}).then((image) => {
			console.log(' 图片路径：' + JSON.stringify(image));
		});
	};

	openPicker1 = () => {
		ImagePicker.openPicker({
			multiple: true
		}).then((images) => {
			console.log(images);
		});
	};

	camera = () => {
		ImagePicker.openCamera({
			width: 300,
			height: 400,
			cropping: true
		}).then((image) => {
			console.log(image);
		});
	};

	render() {
		return (
			<View style={styles.container}>
				<StatusBar animated hidden />
				<TouchableOpacity onPress={this.openPicker} style={styles.btn}>
					<Text>从本地相册选择单幅图像</Text>
				</TouchableOpacity>
				<TouchableOpacity onPress={this.openPicker1} style={styles.btn}>
					<Text>从本地相册调用多个图像</Text>
				</TouchableOpacity>
				<TouchableOpacity onPress={this.camera} style={styles.btn}>
					<Text>拍照</Text>
				</TouchableOpacity>
			</View>
		);
	}
}

const styles = StyleSheet.create({
	container: {
		flex: 1,
		justifyContent: 'center',
		alignItems: 'center'
	},
	btn: {
		padding: 10
	}
});